Skip to content

fix(theme)!: merge ThemeProvider's theme onto the parent and type it ThemeProp - #5239

Merged
Doberjohn merged 2 commits into
mainfrom
@Doberjohn/theme-provider-merge
Nov 19, 2026
Merged

Doberjohn merged 2 commits into
mainfrom
@Doberjohn/theme-provider-merge

Conversation

@Doberjohn

@Doberjohn Doberjohn commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

ThemeProvider put its theme into context unmerged, typed unknown. A partial theme such as { colors: { primary: 'red' } } type-checked and then made Paper's components throw at render, and theme={42} or a removed roundness type-checked too. It now merges theme onto the theme above it with safeMerge, like a component's theme prop, and types it as a partial Theme, as on PaperProvider. A full theme gives the same result.

Related issue

Fixes #5236

Screenshots / Videos

None: rendering doesn't change for a full theme.

Test plan

ThemeProvider put its theme into context as it was, and the prop was
typed unknown, so a partial theme type-checked and then made Paper's
components throw at render. It now merges its theme onto the theme
above it with safeMerge, as a component's theme prop does, passes the
theme above it on when theme is undefined, and is typed as a partial
Theme. PaperProvider and Portal pass themes they have already merged
to an internal provider, so nothing is merged twice.

BREAKING CHANGE: ThemeProvider's theme prop is typed as a partial Theme
instead of unknown, so TypeScript reports values that aren't a theme
and keys the theme doesn't have.
The migration guide now says TypeScript checks ThemeProvider's theme,
and has an entry on the merge. The theming guide shows ThemeProvider
with a partial theme for one part of an app.
@Doberjohn Doberjohn added this to the 6.0.0-beta.0 milestone Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Found potential problems with the pull request:

  • Screenshot or video evidence is missing. Make sure to include one if it affects the UI.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of f068ba5

No open findings.

Reviewed with this repository's own Sentinel configuration (677ab9f2b2cf).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@lukewalczak lukewalczak self-assigned this Nov 19, 2026

@lukewalczak lukewalczak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT 🚀

@Doberjohn
Doberjohn merged commit f62b53f into main Nov 19, 2026
16 checks passed
@Doberjohn
Doberjohn deleted the @Doberjohn/theme-provider-merge branch November 19, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ThemeProvider: theme accepts any value, and a partial theme crashes at render

2 participants